#pragma once

#include <AVUIFreezable.h>

namespace AVUI {
             
class FreezableOperations
{
public:
#pragma region Internal Methods

    /* Re-enable once freezable/animatable rewrite is complete
    static TRefCountedPtr<Freezable> Clone(Freezable* pFreezable)
    {
        if(pFreezable == NULL)
        {
            return NULL;
        }
        return pFreezable->Clone();
    }
    */

    static TRefCountedPtr<Freezable> GetAsFrozen(Freezable* pFreezable)
    {
        if (pFreezable == NULL)
        {
            return NULL;
        }
        return pFreezable->GetAsFrozen();
    }

    static TRefCountedPtr<Freezable> GetAsFrozenIfPossible(Freezable* pFreezable)
    {
        if (pFreezable == NULL)
        {
            return NULL;
        }
        if (pFreezable->get_CanFreeze())
        {
            return pFreezable->GetAsFrozen();
        }
        return pFreezable;
    }

    // These should call add_changed, rewrite once Freezable/Animatable is made consistent.
    static void PropagateChangedHandlers(Freezable* pOldValue, Freezable* pNewValue, EventHandler* pChangedHandler)
    {
        if (pNewValue != NULL && !pNewValue->get_IsFrozen())
        {
            pNewValue->add_ChangedInternal(pChangedHandler);
        }
        if (pOldValue != NULL && !pOldValue->get_IsFrozen())
        {
            pOldValue->remove_ChangedInternal(pChangedHandler);
        }
    }

#pragma endregion Internal Methods
};

}; // namespace AVUI



